package cn.edu.gzist.chapter08.config;

import org.springframework.amqp.core.Binding;
import org.springframework.amqp.core.BindingBuilder;
import org.springframework.amqp.core.DirectExchange;
import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class RabbitDirectConfig {
    public final static String DIRECTNAME = "direct";
    @Bean
    public DirectExchange directExchange() {
        return new DirectExchange(DIRECTNAME);
    }
    @Bean
    public Queue queue() {
        return new Queue("hello.direct");
    }

    @Bean
    public Binding binding(DirectExchange directExchange, Queue queue) {
        return BindingBuilder.bind(queue).to(directExchange).with("direct");
    }
}
